package com.laex;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.List;

public class CategoryListView extends List {

	public CategoryListView(Command back) {
		super("Category List", List.EXCLUSIVE);
		loadList();
		this.addCommand(back);
	}

	public void loadList() {
		String[] sarr = RecordUtil.getCategories();
		this.deleteAll();
		for (int i = 0; i < sarr.length; i++) {
			try {
				this.append(sarr[i], POEUtil.getListItemIcon().getImage());
			} catch (NullPointerException ne) {
			}
		}
	}

	public String getSelectedCategory() {
		String sel = "Misc";
		try {
			sel = this.getString(this.getSelectedIndex());
		} catch (IndexOutOfBoundsException ib) {
		}
		return sel;
	}
}
